package cn.com.qiancheng.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import com.mysql.jdbc.Driver;

public class DbUtil {
	private static final String URL = "jdbc:mysql://192.168.0.189:3306/qiancheng?characterEncoding=UTF-8";
	private static final String USER_NAME = "qiancheng";
	private static final String PASSWORD = "qiancheng";
	private static Connection con = null;

	public static Connection openConnection() throws SQLException {
		DriverManager.registerDriver(new Driver());
		con = DriverManager.getConnection(URL, USER_NAME, PASSWORD);
		return con;
	}

	public static void closeConnection() throws SQLException {
		if (con != null) {
			con.close();
		}
	}
}
